#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void InsertSorting(int* a, int n) {
	for (int i = 0; i < n - 1; i++) {
		int x = i;
		int y = a[x + 1];
		while (x >= 0) {
			if (a[x] > y) {
				a[x + 1] = a[x];
				x--;
			}
			else {
				break;
			}
		}
		a[x + 1] = y;
	}
	for (int i = 0; i < n; i++) {
		printf("%d ", a[i]);
	}
	printf("\n");
}
void HillSorted(int* a, int n) {
	int gad = n;
	while (gad > 1) {
		gad /= 2;
		for (int i = 0; i < n - gad; i++) {
			int x = i;
			int y = a[i + gad];
			while (x >= 0) {
				if (a[x] > y) {
					a[x + gad] = a[x];
				}
				else {
					break;
				}
			}
			a[x + gad] = y;
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d ", a[i]);
	}
	printf("\n");
}
int main() {
	srand(time(NULL));
	int a[10] = { 0 };
	int x = sizeof(a) / sizeof(int);
	for (int i = 0; i < x; i++) {
		a[i] = rand() % 10;
		printf("%d ", a[i]);
	}
	printf("\n");
	InsertSorting(a, x);
	HillSorted(a, x);
}